/**
 * @Description Ext.translate for ExtJS 2.x and 3.x; Auto translation with Google Translation API (java/php server side)
 * @author  Tomislav Milkovic
 * @license LGPLv3 http://www.opensource.org/licenses/lgpl-3.0.html
 * @version 1.7, 16.10.2009.
 */


/**
 * Ext.translate.TranslateRenderer
 * @description Updater for HTML elements with automatic translation to selected language
 */
Ext.namespace('Ext.translate');


Ext.translate.TranslateRenderer = function(){};
Ext.translate.TranslateRenderer.prototype = {    
     render : function(el, response, updateManager, callback){  

		var cbFn = function(){
			el.update(arguments[0][Ext.translate.currentLanguage], updateManager.loadScripts, callback);
		};
		var obj={};
		obj[Ext.translate.defaultLanguage] =  response.responseText; 
		Ext.translate.Cache.translate(obj, {callback : cbFn, params:arguments});
        
    }
};

Ext.Updater.override({
   getDefaultRenderer: function() {
      return new  Ext.translate.TranslateRenderer();
   }
});